using System.IO;
using GHIElectronics.NETMF.Glide.UI;

namespace Melody_Glider.GUIContent
{
    class DeleteQuestionBox: WindowFrame
    {
        private readonly GUI _gui;
        private readonly SystemState _conditions;

        public DeleteQuestionBox(GUI gui, SystemState state)
        {
            _gui = gui;
            _conditions = state;
        }

        protected override void InitButtons()
        {
            var yesBtn = (Button)ThisWindow.GetChildByName("YesButton");
            yesBtn.TapEvent += YesBtnTapEvent;

            var noBtn = (Button)ThisWindow.GetChildByName("NoButton");
            noBtn.TapEvent += NoBtnTapEvent;
        }

        private void YesBtnTapEvent(object sender)
        {
            var path = _conditions.Drive.Volume.RootDirectory + @"\" + _conditions.ActiveFileName + ".tsm";
            File.Delete(path);

            _gui.LoadMenuWindow.SetToMain();
        }

        private void NoBtnTapEvent(object sender)
        {
            _gui.LoadMenuWindow.SetToMain();
        }
    }
}
